from django.db import models

# Create your models here.

class Canteen(models.Model):

    id = models.DecimalField(max_digits=2, decimal_places=0, primary_key=True)
    adm_id = models.DecimalField(max_digits=10, decimal_places=0)
    name = models.CharField(max_length=10)
    address = models.CharField(max_length=20)
    telNum = models.DecimalField(max_digits=11, decimal_places=0)

    class Meta:
        permissions = ()
        db_table = 'canteen'

class storeInfo(models.Model):
    id = models.DecimalField(max_digits=3, decimal_places=0, primary_key=True)
    sel_id = models.DecimalField(max_digits=10, decimal_places=0)
    can_id = models.DecimalField(max_digits=2, decimal_places=0)
    name = models.CharField(max_length=10)
    reletiveAddress = models.CharField(max_length=20)
    telNum = models.DecimalField(max_digits=11, decimal_places=0)

    class Meta:
        permissions = ()
        db_table = 'store'

# class foodInfo(models.Model):
#
#     canteen_name = models.CharField(max_length=10)
#     store_name = models.CharField(max_length=10)
#     food_name = models.CharField(max_length=10, primary_key=True)
#     price = models.IntegerField()
#
#     class Meta:
#         permissions = ()
#         db_table = 'foodinfo'

class food(models.Model):
    id = models.DecimalField(max_digits=4, decimal_places=0, primary_key=True)
    sto_id = models.DecimalField(max_digits=3, decimal_places=0)
    name = models.CharField(max_length=10)
    price = models.IntegerField()

    class Meta:
        permissions = ()
        db_table = 'food'

class order(models.Model):
    SELVALUE = (
        (0, '未完成'),
        (1, '已完成'),
    )

    id = models.IntegerField(primary_key=True)
    nor_id = models.DecimalField(max_digits=10, decimal_places=0)
    orderTime = models.CharField(max_length=10)
    totalPrice = models.IntegerField()
    state = models.DecimalField(max_digits=1, decimal_places=0, choices=SELVALUE)

    class Meta:
        permissions = ()
        db_table = 'userorder'

class orderedFood(models.Model):
    use_id = models.IntegerField()
    uid = models.DecimalField(max_digits=4, decimal_places=0)
    amount = models.IntegerField()

    class Meta:
        unique_together = (("use_id", "uid"),)
        permissions = ()
        db_table = 'orderedFood'

class orderInfo(models.Model):
    SELVALUE = (
        (0, '未完成'),
        (1, '已完成'),
    )

    id = models.IntegerField(primary_key=True)
    orderTime = models.CharField(max_length=10)
    store_name = models.CharField(max_length=10)
    food_name = models.CharField(max_length=10)
    price = models.IntegerField()
    amount = models.IntegerField()
    totalPrice = models.IntegerField()
    account = models.CharField(max_length=10)
    deliveryAddress = models.CharField(max_length=20)
    telNum = models.DecimalField(max_digits=11, decimal_places=0)
    state = models.DecimalField(max_digits=1, decimal_places=0, choices=SELVALUE)

    class Meta:
        permissions = ()
        db_table = 'orderinfo'

class UserInfo(models.Model):
    SELVALUE = (
        (0, '管理员'),
        (1, '商家'),
        (2, '普通用户'),
    )

    account = models.CharField(max_length=10, primary_key=True)
    password = models.CharField(max_length=20)
    userName = models.CharField(max_length=10)
    userType = models.DecimalField(max_digits=1, decimal_places=0, choices=SELVALUE)
    telNum = models.DecimalField(max_digits=11, decimal_places=0)

    class Meta:
        permissions = ()
        db_table = 'userinfo'

class Administrator(models.Model):
    id = models.DecimalField(max_digits=10, decimal_places=0, primary_key=True)
    account = models.CharField(max_length=10)
    realName = models.CharField(max_length=10)

    class Meta:
        permissions = ()
        db_table = 'administrator'

class Seller(models.Model):
    id = models.DecimalField(max_digits=10, decimal_places=0, primary_key=True)
    account = models.CharField(max_length=10)
    realName = models.CharField(max_length=10)

    class Meta:
        permissions = ()
        db_table = 'seller'

class NormalUser(models.Model):
    id = models.DecimalField(max_digits=10, decimal_places=0, primary_key=True)
    account = models.CharField(max_length=10)
    realName = models.CharField(max_length=10)
    deliveryAddress = models.CharField(max_length=20)

    class Meta:
        permissions = ()
        db_table = 'normaluser'